package admin;

import android.app.Activity;

public class AdminActivity extends Activity {/*
	private static String mToken = "3.f0b39c30748e940ce483a0ab30603bc1.2592000.1357129028.3744430078-435493";
	private Button mGetTokenBtn ;
	private Button mCreateTabelBtn ;

	private static final String mTableUrl = "http://pcs.baidu.com/rest/2.0/structure/table";
	private static final String mRecordUrl = "http://pcs.baidu.com/rest/2.0/structure/data";
	private static final String mCreateTableJson = "{" +
			"\"table\" : \"control\"," +
			"\"column\" :{" +
			"	\"id\":" +
			"		{\"description\" : \"\"," +
			"		 \"type\" : \"int\"," +
			"		 \"required\" : true " +
			"	    }," +
			"	\"stat\":" +
			"		{\"description\" : \"\"," +
			"		 \"type\" : \"int\"," +
			"		 \"required\" : true " +
			"	    }" +
			"	}," +
			"\"index\":" +
			"{\"id_index\" : {\"column\" : {\"id\" : 1}" +
			"}}}";
	private static final String mbApiKey = "rq9WOZRCcVxpTOglxsaYzcEK";//
	//12-03 12:17:11.228: INFO/System.out(625): -->>>>Token: 3.f0b39c30748e940ce483a0ab30603bc1.2592000.1357129028.3744430078-435493    User name:ourfishgreat
	
	private HttpClientUtil aHttpClient;
	@Override
    public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.admin);
        TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
        Toast.makeText(getApplicationContext(), "Phone Number: "+phoneMgr.getLine1Number()+"",Toast.LENGTH_SHORT).show();
        mGetTokenBtn = (Button)findViewById(R.id.get_access_token);
        mGetTokenBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            BaiduOAuth oauthClient = new BaiduOAuth();
            oauthClient.startOAuth(AdminActivity.this, mbApiKey, new String[]{"basic"},new BaiduOAuth.OAuthListener() {
                    @Override
                    public void onException(String msg) {
                        Toast.makeText(getApplicationContext(), "Login failed " + msg, Toast.LENGTH_SHORT).show();
                    }
                    @Override
                    public void onComplete(BaiduOAuthResponse response) {
                        if(null != response){
                        	mToken = response.getAccessToken();
                            Toast.makeText(getApplicationContext(), "Token: " + mToken + "    User name:" + response.getUserName(), Toast.LENGTH_SHORT).show();
                        }
                    }
                    @Override
                    public void onCancel() {
                        Toast.makeText(getApplicationContext(), "Login cancelled", Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });
        aHttpClient = HttpClientUtil.newInstance(this, false,Http.COOKIE_EXPIRES_KEY);
        mCreateTabelBtn = (Button)findViewById(R.id.button1);
        mCreateTabelBtn.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				new Thread(new Runnable(){

					@Override
					public void run() {
						Map<String, String> params = new HashMap<String,String>();
						params.put("method","create");
						params.put("access_token",mToken);
						params.put("param",mCreateTableJson);
						aHttpClient.syncConnect(mTableUrl,
								params, HttpClientUtil.METHOD.POST,new IHttpRequestCallback(){
							@Override
							public void execute(String json) {
								System.out.println("--->>>---json:"+json);
							}
						});
					}
		        	
		        }).start();
				
			}
        	
        });
	}
*/}
